package com.springboot.myspringbootframework.web.exception;

import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestControllerAdvice
public class MyExceptionHandler {

    @ExceptionHandler(MyException.class)
    @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
    public Map<String,Object> handlerMyExcetion(MyException ex){
        Map<String,Object> result = new HashMap<>();
        result.put("message",ex.getMessage());
        result.put("code",500);
        return result;
    }
}
